<template>
  <div id="app">
    <nav>
      <router-link to="/">Home</router-link> |
      <router-link to="/about/wid_52622">About</router-link> |


<!--      使用编程式路由,即通过事件-->
      <button @click="toNote">Note</button> |
      <router-link to="/user">用户信息页面</router-link>
    </nav>
<!--    路由展示的页面位置-->
    <router-view/>
  </div>
</template>
<script>
export default {
  name: 'App',
  methods:{
   toNote(){
     //编程式路由的关键
     //这么写重复点击会报错
    // this.$router.push("/note")

    const currentRoute =  this.$router.currentRoute;

    if(currentRoute.path !== "/note"){
      //这次不但要跳转页面(路由)还需要传递数据
      this.$router.push({
        path:"/note",
        query:{//通过query的方式携带参数
          message:"国足进步了"
        }
      })
    }
   }
  },
}
</script>
<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

nav {
  padding: 30px;
}

nav a {
  font-weight: bold;
  color: #2c3e50;
}

nav a.router-link-exact-active {
  color: #42b983;
}
</style>
